package com.ruoyi.data.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.data.domain.DataMoney;
import com.ruoyi.data.mapper.DataMoneyMapper;
import com.ruoyi.data.service.IDataMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 消费记录Service业务层处理
 *
 * @author zzp
 * @date 2022-10-21
 */
@Service
public class DataMoneyServiceImpl implements IDataMoneyService {
    @Autowired
    private DataMoneyMapper dataMoneyMapper;

    /**
     * 查询消费记录
     *
     * @param id 消费记录主键
     * @return 消费记录
     */
    @Override
    public DataMoney selectDataMoneyById(Long id) {
        return dataMoneyMapper.selectDataMoneyById(id);
    }

    /**
     * 查询消费记录列表
     *
     * @param dataMoney 消费记录
     * @return 消费记录
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<DataMoney> selectDataMoneyList(DataMoney dataMoney) {
        return dataMoneyMapper.selectDataMoneyList(dataMoney);
    }

    /**
     * 新增消费记录
     *
     * @param dataMoney 消费记录
     * @return 结果
     */
    @Override
    public int insertDataMoney(DataMoney dataMoney) {
        dataMoney.setCreateTime(DateUtils.getNowDate());
        return dataMoneyMapper.insertDataMoney(dataMoney);
    }

    /**
     * 修改消费记录
     *
     * @param dataMoney 消费记录
     * @return 结果
     */
    @Override
    public int updateDataMoney(DataMoney dataMoney) {
        dataMoney.setUpdateTime(DateUtils.getNowDate());
        return dataMoneyMapper.updateDataMoney(dataMoney);
    }

    /**
     * 批量删除消费记录
     *
     * @param ids 需要删除的消费记录主键
     * @return 结果
     */
    @Override
    public int deleteDataMoneyByIds(Long[] ids) {
        return dataMoneyMapper.deleteDataMoneyByIds(ids);
    }

    /**
     * 删除消费记录信息
     *
     * @param id 消费记录主键
     * @return 结果
     */
    @Override
    public int deleteDataMoneyById(Long id) {
        return dataMoneyMapper.deleteDataMoneyById(id);
    }

    @Override
    public List<DataMoney> selectDataMoneyListByUserId(Long userId, String moneyType) {
        return dataMoneyMapper.selectDataMoneyListByUserId(userId, moneyType);
    }
}
